import { Component, Injector } from '@angular/core';
import { AppComponentBase } from '@shared/common/app-component-base';
import { UpdateReplyInput, WorkFlowManagerServiceProxy } from '@shared/service-proxies/service-proxies';
import { BsModalRef } from 'ngx-bootstrap/modal';
import { merge as _merge } from 'lodash-es';
import { finalize } from 'rxjs/operators';
import { Observable } from 'rxjs';

@Component({
    templateUrl: './reply-message-update-modal.component.html'
})
export class ReplyMsgUpdateModelComponent extends AppComponentBase {

    callback: {(replyMsg: string):void};

    isShown = false;
    isInitialized = false;

    loading = false;
    saving = false;

    replyMsg: string = '';

    constructor(
        injector: Injector,
        public bsModalRef: BsModalRef,
        private _workFlowManagerService: WorkFlowManagerServiceProxy
    ) {
        super(injector);
    }

    close(): void {
        this.bsModalRef.hide();
    }

    shown(replyMsg: string): void {
        this.isShown = true;
        
        this.replyMsg = replyMsg;

        this.isInitialized = true;
    }

    save() {
        this.saving = true;
        this.callback(this.replyMsg);
    }
}
